package com.ruoyi.iot.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.iot.domain.ExtraAgent;
import com.ruoyi.iot.service.IExtraAgentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 系统用户额外的代理(店铺)配置Controller
 * 
 * @author hly
 * @date 2024-01-16
 */
@RestController
@RequestMapping("/iot/extraAgent")
public class ExtraAgentController extends BaseController
{
    @Autowired
    private IExtraAgentService extraAgentService;

    /**
     * 查询系统用户额外的代理(店铺)配置列表
     */
    @PreAuthorize("@ss.hasPermi('iot:extraAgent:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExtraAgent extraAgent)
    {
        startPage();
        List<ExtraAgent> list = extraAgentService.selectExtraAgentList(extraAgent);
        return getDataTable(list);
    }

    /**
     * 导出系统用户额外的代理(店铺)配置列表
     */
    @PreAuthorize("@ss.hasPermi('iot:extraAgent:export')")
    @Log(title = "系统用户额外的代理(店铺)配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExtraAgent extraAgent)
    {
        List<ExtraAgent> list = extraAgentService.selectExtraAgentList(extraAgent);
        ExcelUtil<ExtraAgent> util = new ExcelUtil<ExtraAgent>(ExtraAgent.class);
        util.exportExcel(response, list, "系统用户额外的代理(店铺)配置数据");
    }

    /**
     * 获取系统用户额外的代理(店铺)配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('iot:extraAgent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(extraAgentService.selectExtraAgentById(id));
    }

    /**
     * 新增系统用户额外的代理(店铺)配置
     */
    @PreAuthorize("@ss.hasPermi('iot:extraAgent:add')")
    @Log(title = "系统用户额外的代理(店铺)配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExtraAgent extraAgent)
    {
        return toAjax(extraAgentService.insertExtraAgent(extraAgent));
    }

    /**
     * 修改系统用户额外的代理(店铺)配置
     */
    @PreAuthorize("@ss.hasPermi('iot:extraAgent:edit')")
    @Log(title = "系统用户额外的代理(店铺)配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExtraAgent extraAgent)
    {
        return toAjax(extraAgentService.updateExtraAgent(extraAgent));
    }

    /**
     * 删除系统用户额外的代理(店铺)配置
     */
    @PreAuthorize("@ss.hasPermi('iot:extraAgent:remove')")
    @Log(title = "系统用户额外的代理(店铺)配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(extraAgentService.deleteExtraAgentByIds(ids));
    }
}
